package domain

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"listenboos-common/db"
	"live/dao"
	"live/model"
	"live/repo"
)

type LiveRoomDomain struct {
	liveRoomRepo repo.LiveRoomRepo
}

func (d LiveRoomDomain) FindRoomByUserId(ctx context.Context, userId int64) (*model.LiveRoom, error) {
	room, err := d.liveRoomRepo.FindRoomByUserId(ctx, userId)
	if err != nil {
		logx.Errorf("获取直播标签数据库内部错误%v", err)
		return nil, err
	}
	return room, nil
}

func NewLiveRoomDomain(db *db.ListenDB) *LiveRoomDomain {
	return &LiveRoomDomain{
		liveRoomRepo: dao.NewLiveRoomDao(db),
	}
}
